System and method for preventing timeout of a client

ABSTRACT

A system for preventing timeout of a client interface accessing a main Java Servlet executing in a first thread which monitors an application executing in a second thread. A task status object is accessed by the application to post its completion state and by the client interface responsive to a state refresh request to post a state refresh response including the completion state to the client. The state refresh response selectively includes a refresh attribute instructing the client to periodically post the state refresh request. Upon the application going to completion or error state, subsequent state refresh responses do not include the refresh attribute.

CROSS REFERENCE TO RELATED APPLICATION

This is a continuation of U.S. patent application Ser. No. 10/126,484, filed Apr. 19, 2002, entitled “System and Method for Preventing Timeout of a Client”, which is herein incorporated by reference. This application claims priority under 35 U.S.C. §120 of U.S. patent application Ser. No. 10/126,484, filed Apr. 19, 2002.

BACKGROUND OF THE INVENTION

1. Technical Field of the Invention

This invention relates to preventing timeout. More particularly, it relates to preventing timeout of a browser in a client/server system.

2. Background Art

Java Servlets are used in conjunction with web browsers. The web browser acts as the client. The servlet resides on the server side. When an event occurs on a web page, such as clicking on a “submit” button, user-entered data on the page, such as information to make an on-line purchase of goods, may be sent to the servlet for processing. The servlet then receives that data and takes appropriate actions, such as verifying the credit card number and checking inventory to make sure the purchase can be fulfilled.

If the servlet takes a lengthy period of time to process that data, the web browser may time-out and show an error message to the effect that the page being requested can not be obtained or that communication was lost with the web server. The servlet will eventually finish processing the user's data, but because of the timeout, the web page that the servlet returns to the browser after the data has been processed will go undisplayed.

Even if the data is able to be processed within the time-out period enforced by the browser, the processing may still be lengthy. Without a monitoring system that uses words and/or a pictorial to indicate the progress of the data processing to the user, the user would only see an hourglass while the mouse is hovering over the browser. This has been a source of frustration for users encountering this phenomenon.

It is an object of the invention to provide a system and method for avoiding premature timeout of a browser while awaiting completion of an application.

SUMMARY OF THE INVENTION

A system and method for preventing timeout by initializing an application for execution; initializing a client state with a refresh attribute, the refresh attribute specifying a time interval for posting state refresh requests; responsive to the state refresh request from the client, returning to the client a refreshed application state selectively including a refresh attribute while the application is executing and not including the refresh attribute upon said application completing execution or going into an error state.

Other features and advantages of this invention will become apparent from the following detailed description of the presently preferred embodiment of the invention, taken in conjunction with the accompanying drawings.

BRIEF DESCRIPTION OF THE DRAWING

FIG. 1 represents a server/client system in accordance with the preferred embodiment of the invention.

FIG. 2 is a diagrammatic representation of the threads of FIG. 1.

FIGS. 3A-3C are a flow chart of an exemplary embodiment of the method of the invention.

FIG. 4 is class diagram illustrating thread I of FIG. 2.

DETAILED DESCRIPTION OF PREFERRED EMBODIMENTS

In accordance with the preferred embodiment of the invention, a system and method for monitoring task progress in a Java servlet is used to avoid premature timeout of a browser. In an exemplary embodiment, on periodic request from the browser, a bar graph representation of percentage of the task completion is returned from the servlet in a hypertext language markup, such as a JavaScript/HTML markup, on short time intervals (i.e., every 5 seconds). This bar graph can also be accompanied by text displaying any pertinent progress information. The instruction to request an updated representation of the progress is received by the browser in a meta tag from the servlet. This time interval is set to be less than the browser time-out value, so the browser will never time-out. The progress representation allows the user to see and understand how much progress has been made in completing the task, the browser does not timeout, and the user can estimate when the task will be completed.

Referring to FIG. 1, server 20 and client 30 are coupled through a network 22. Server 20 has a servlet 24 running in thread I and an application task 26 running in thread II. Client 30 has a browser, in which progress bar 34 may be displayed responsive to servlet 24 indicating the state of completion of application task 26 in thread II.

In accordance with the preferred embodiment of the invention, a meta tag is sent by servlet 24 in a first thread to keep a browser 32 from timing out during execution of application task 26 in a second thread.

A meta tag is a piece of html markup that describes a document, and can define an interval that sets a refresh interval: after that interval, a client returns to the server to get a new copy of the page being displayed at client. This meta tag is an existing part of html, and is used by the preferred embodiment of the present invention to refresh an html page with information from a Java servlet.

HTML and JavaScript at client browser displays progress bar/text at browser. Each time interval t the client goes to the server servlet 24 for an update for the progress bar 34. That progress bar is tracking the progress of an application on a separate thread II.

Servlet 24 responds by building a new HTML page with JavaScript to send back to client 30 a new display for browser display 32 with progress bar 34 updated to reflect current progress of application 26. When application 26 on thread II completes or goes to error state, the response from servlet 24 does not include the meta tag—so the page is done and no further refreshing is done in response to a meta tag.

Referring to FIG. 2, application 28 runs in thread II 26, and as is represented by line 35 periodically posts its status (completion or error state) to task status 23, which runs in thread I 24. Thread I also includes user interface 25. As is represented by line 36, user interface accesses task status 23 to ascertain the current status of application 28. As is represented by line 37, user interface initializes user 31 to an initial state which includes a meta tag having a refresh attribute t. As is further represented by line 37, user 31, responsive to that refresh attribute t, periodically posts a refresh request to user interface 25, which responds with a new state including an updated representation of the status of application 28. Until application 28 posts completion or error to task status 23, user interface 25 will respond to refresh requests from user 31 with a state refresh that includes the refresh attribute. Upon task status 23 being posted by application 28 to error or complete state, the response from user interface 25 to user 31 will not include the refresh attribute t and user 31 ceases posting periodic refresh requests to user interface 25. Refresh attribute t is set at a time interval less than the timeout period for user 31 so that, as long as user 31 receives and responds to a state refresh including the meta tag, user 31 will not timeout.

Referring to FIGS. 3A-3C in connection with FIG. 1, an exemplary embodiment of the invention is presented. In step 40, a Java user interface class presents a series of HTML screens (a wizard) to the user, each for collecting data from him for setting up an application task 28 in thread II. Between each screen, in step 42, the data on the page is submitted to the Java Servlet 24 and is stored in this Java class. In an exemplary embodiment, this servlet class 24 is represented by B2BCatalogPublishWizardForm. Once all data has been collected from the user, in step 44, a subclass of ProgressBarTask is created (in this example, PublishTask). All data needed to perform the publish task is passed on to this newly created object.

In step 46, the new ProgressBarTask creates a TaskStatus object, which holds the percentage complete of the task to run, and some message text set by the object user. The ProgressBarTask also owns a ProgressBar object.

Once all data is sent to the ProgressBarTask subclass (i.e. PublishTask) from the user interface class, the actual long task (such as a publishing application 28) is ready to be run. In step 48, application task 28 is run in a separate thread II from servlet 24, which runs in thread I. The ProgressBarTask subclass object is sent to the classes handling the long operation (publish) in that separate thread. Those classes are in charge of using the PublishTask object to set the TaskStatus that it owns with new percentages and messages when it reaches specific milestones. In step 50, updates to task status are periodically posted to the progress bar object by progress bar task. This is the data that will be read every t seconds when an update is required. In step 52, servlet 24 sends to browser 32 an HTML page with progress indicator 34 (initially set to 0% completion) and a meta tag with a refresh attribute of t. In step 54, browser 32 displays progress bar 34.

In step 56, periodically, such as when an update is required to the HTML page with progress indicator 34, the ProgressBar task takes the data from the TaskStatus object, and gives it to the ProgressBar object. The ProgressBar object uses that data to create a new HTML page to be returned in step 60 by the Java Servlet 24 to browser 32. In step 60, this HTML page contains a meta tag with a refresh attribute set to a default of t seconds. This will cause in step 54 a post to the Java Servlet 24 in t seconds, causing in step 56 the user interface class (i.e. B2BCatalogPublishWizardForm) to ask the ProgressBarTask subclass to get a new HTML page from ProgressBar. The meta tag with the refresh attribute is returned in step 60 in the HTML markup until in step 58 an error in or completion of task 26 is detected and, at that time, in step 62 the interface returns the HTML markup without the meta tag. This prevents an infinite refresh of the progress HTML page. When all updates are finished, in step 64 a button is presented on the HTML page that takes the user to another page so that he can continue with his use of the browser.

Summarizing, in this embodiment of the invention, a ProgressBarTask subclass is shared between two threads I and II. Thread I consumes the TaskStatus data from it, and user interface thread II updates it. Thread I is the user interface class which can make calls to get a new HTML page to show the user the current task status, and the thread II is the class or classes performing the actual task 26.

The object model of FIG. 4 and Tables I-IV illustrate how a progress indicator meta tag having a refresh attribute is used to prevent browser time-out during application execution when publishing large electronic catalog in Connect for the IBM iSeries. All objects of FIG. 4 reside within Java servlet 24 (iSeries Connect is one Java Servlet). The Java code of Tables I-IV illustrate an exemplary embodiment of the invention for iSeries Connect.

Referring to FIG. 4, a class diagram illustrates progress bar task 10 (Table I), task status 12 (Table II), progress bar 14 (Table III), publish task 16 (Table IV), and application wizard 18. As is represented by line 11, progress bar task class 10 has a progress bar class 14. As is represented by line 13, progress bar task class 10 has a task status class 12. As is represented by line 15, publish task 16 extends progress bar task class 10. As is represented by line 17, application wizard class 18 has a publish task class 16.

Progress bar task class 10 returns html to browser 32 which contains progress bar 34 information. Table I sets forth a Java code statement of an exemplary progress bar task class 10. TABLE I PROGRESSBAR TASK #status:TaskStatus #progressBar:ProgressBar #m_taskException:B2BCatalogExeption=null #m_trace:B2BServletTraceLogger #m_catBundle:CatalogResourceBundle #ProgressBarTask( ) #ProgressBarTask(refreshRate:int) +getProgressHTML( ):String +getProgressHTMLForError( ):String +getStatus( ):TaskStatus +getTaskException( ):B2BCatalogException +setTaskException(taskException:B2BCatalogException)

Task status class 12 contains information on how complete is thread II 26, or its error state. A Java code representation of an exemplary task status class 12 is set forth in Table II. TABLE II TASKSTATUS −m_statusMsg:String=“” −m_percentComplete:Integer −m_onLastStep:Boolean −m_catBundle:CatalogResourceBundle +TaskStatus( ) +setTaskStatus(statusMsg:String.percentComplete:int):void +onLastStep( ):boolean statusMsg:String percentComplete:int onLastStep:boolean

Progress bar class 14 is a data holder for the refresh rate on the meta tag of browser 32, and is also used as an interface to update application task 28 thread II 26 progress. A Java code representation of an exemplary progress bar class 14 is set forth in Table III. TABLE III PROGRESS BAR −REFRESH_URL:String=B2BPaths.getServletURLPath( )+“/Content” −m_refreshRate:Int=5 −m_trace:B2BServletTraceLogger −m_catBundle:CatalogResourceBundle −progressHTMLStr:String +ProgressBar( ) +ProgressBar(refreshRate:int) +updateProgress(percentComplete:int,statusMsg:String,  isFinalStep:boolean):String +updateProgress(percentComplete:int,statusMsg:  String,errorOccurred:boolean,isFinalStep:boolean) refreshRate:Int

Publish task class 16 is an extended class of progress bar task class 10 with specific information for application task 28 thread II 26 (what is it and what kind of data does it need.) A publish task is a subclass of progress bar task. It is needed because a publish is a long operation that needs to be monitored by a progress bar. The kind of data it needs, for example, is the catalog format that will be published, who the catalog supplier is, if it is a local or remote catalog, etc. Table IV contains a Java code representation of an exemplary publish task class 16. TABLE IV PUBLISH TASK −m_mpFormat:MarketplaceFormat=null −m_result:PublishResult=null −m_catalog:Catalog=null −m_associateMP:B2BSupplierMarketplaceAssociationElemen... −m_priceProfiles:Vector=null −m_destination:PublishDestination=null −m_localOrRemote:int −resultsSet:Boolean −resultIsSet:Boolean −m_catBundle: CatalogResourceBundle +PublishTask(mpFormat:MarketplaceFormat) +publish(catalog:Catalog,associateMP:  B2BSupplierMarketplaceAssociation) +run( ):void publishResult:PublishResult

Application wizard class 18 is a method for starting application task 28 thread II 26. Upon completing, application wizard class 18 induces progress bar 34. Class 18 is a wizard that interacts with the user to obtain information on how to publish, for example, an electronic catalog. At the end of the wizard, when a finish button is clicked, publish task class 16 is instantiated. An example of such a wizard is the B2BCatalogPublishWizardForm at

com.ibm.connect.config.B2BWizardForm.

for the IBM iSeries Connect product, a product that allows suppliers to operate in secure market places to leverage the Internet. In publish task class 16, the statement

+run( ):void

is what spawns thread II 26.

When publish task class 16 is created, progress bar class 10 gets created as a consequence (publish task class 16 is a sub class of progress bar task 10). When progress bar task 10 is created, task status class 12 gets created as a consequence with an initial progress state of null. In publish task class 16, there is a run statement

+run( ):void

that spawns application task 28 in thread II 26 (the task that will take a long time (that is, a time longer than the timeout time of client browser 32), the progress of which will be displayed in progress bar 34.) At this point there exists a task (progress bar task 10) in application task 28 thread II 26, which has a reference to task status class 12 in a separate thread which updates task status whenever it is necessary. Both servlet thread 24 and application task 28 have access to task status class 12, with thread 24 being the consumer and thread 26 being the maintainer of task status class 12.

Thread II 26, once spawned, sets/resets its progress bar by executing the Java code

+setTaskStatus(statusMsg:String.percentComplete:int):void

on the task status class 12.

When task status class 12 is set up, no progress is complete, and a status bar 34 with zero complete is returned to client 30 by servlet thread I 24 which includes the metatag to refresh the page. This metatag is contained in progress bar task class 10 at

+getProgressHTML( ):String

Application task 28 on thread II updates task status class 12, and progress bar task class 10 builds an HTML response to client 30 showing in the statement

+getProgressHTML( ):String

the new state of progress which had been set in task status class 12 by thread II 26 at

+setTaskStatus(statusMsg:String.percentComplete:int):void

That new

+getProgressHTML( ):String

includes a new meta tag which instructs client 30 to refresh again in time t.

If application task 28 on thread II is 100% complete or in error state, progress bar task class 10 returns HTML without the refresh meta tag and a progress bar which shows a completion or stopped state.

ADVANTAGES OVER THE PRIOR ART

It is an advantage of the invention that there is provided a system and method for avoiding premature timeout of a browser while awaiting completion of an application.

ALTERNATIVE EMBODIMENTS

It will be appreciated that, although specific embodiments of the invention have been described herein for purposes of illustration, various modifications may be made without departing from the spirit and scope of the invention. In particular, it is within the scope of the invention to provide a computer program product or program element, or a program storage or memory device such as a solid or fluid transmission medium, magnetic or optical wire, tape or disc, or the like, for storing signals readable by a machine, for controlling the operation of a computer according to the method of the invention and/or to structure its components in accordance with the system of the invention.

Further, each step of the method may be executed on any general computer, such as IBM Systems designated as zSeries, iSeries, xSeries, and pSeries, or the like and pursuant to one or more, or a part of one or more, program elements, modules or objects generated from any programming language, such as C++, Java, P1/1, Fortran or the like. And still further, each said step, or a file or object or the like implementing each said step, may be executed by special purpose hardware or a circuit module designed for that purpose.

Accordingly, the scope of protection of this invention is limited only by the following claims and their equivalents. 

1. A server system for preventing time out, comprising: a first thread executing in said server system, said first thread comprising a client interface for interfacing to a client of said server system; a second thread executing in said server system, said second thread comprising a server application for servicing a first request by said client, wherein said client automatically times out if a response to said request is not received in said client within a pre-determined time-out period; a task status object accessed by said server application to post completion state of said server application and by said client interface responsive to receiving a state refresh request from said client to post a state refresh response; and wherein, responsive to receiving a state refresh request from said client, said client interface transmits a state refresh response to said client, said state refresh response comprising a completion state of said server application in generating a response to said first request and selectively including a refresh attribute instructing said client to post said state refresh request again before expiration of said pre-determined time-out period, wherein posting said state refresh request by said client responsive to said refresh attribute prevents time-out in said client, said refresh attribute being selectively included when said server application has not completed generating a response to said first request.
 2. The system of claim 1, said refresh attribute specifying a time interval for posting state refresh requests.
 3. The system of claim 1, wherein said state refresh response comprises a hypertext markup language (HTML) metatag identifying said completion state of said server application, and selectively including said refresh attribute.
 4. The system of claim 1, wherein state refresh response includes a hypertext markup language representation of a progress bar for displaying said completion state.
 5. The system of claim 4, further comprising: a progress bar task for storing a progress bar representation of said completion state; and a publish task responsive to said state refresh request for accessing said progress bar task for said state of completion and deriving a hypertext markup language representation of a progress bar for displaying said application state. 